@include('Home.head')
<body>
<div class="container" id="app">
    <header data-am-widget="header" class="am-header am-header-default my-header">
        <div class="am-header-left am-header-nav">
            <a  onclick="javascript:history.back(-1);" class="">
                <i class="am-header-icon am-icon-chevron-left"></i>
            </a>
        </div>
        <h1 class="am-header-title">
            <a href="#title-link" class="">手机充值</a>
        </h1>
        {{--<div class="am-header-right am-header-nav">--}}
        {{--<a href="#right-link" class="">--}}
        {{--<i class="am-header-icon  am-icon-home"></i>--}}
        {{--</a>--}}
        {{--</div>--}}
    </header>
    <div class="gray-panel">
        <div class="am-tabs" data-am-tabs>
            <ul class="am-tabs-nav am-nav am-nav-tabs">
                <li class="am-active"><a href="#tab1">会员充值</a></li>
                <li><a href="#tab2">修改资料</a></li>
            </ul>
            <div class="am-tabs-bd">
                <div class="am-tab-panel am-fade am-in am-active" id="tab1">
                    <div class="paoduct-title-panel">
                        <form class="am-form am-form-inline">
                            <hr data-am-widget="divider"  style="" class="am-divider-default am-margin-bottom-sm"/>
                            <div class="am-form-group am-form-icon">
                                <i class="am-icon-phone"></i>
                                <input type="text" pattern="\d*" v-model="user.phone" v-on:blur="upperCase()" class="am-form-field am-radius" placeholder="充值账号">
                            </div>
                            <p>充值用户：@{{ user_name }}</p>
                            <hr data-am-widget="divider"  style="" class="am-divider-default am-margin-bottom-sm"/>
                            <div class="am-form-group am-form-icon">
                                <i class="am-icon-yen"></i>
                                <input type="text" v-model="user.credit1" class="am-form-field am-radius" placeholder="购物积分">
                            </div>
                            <p>操作金额：@{{ Zcredit1 }}</p>
                            <p>积分余额：@{{ credit1 }}</p>
							
                            <div class="am-form-group am-form-icon">
                                <i class="am-icon-yen"></i>
                                <input type="text" v-model="user.credit2" class="am-form-field am-radius" placeholder="奖金积分">
                            </div>
                            <p>操作金额：@{{ Zcredit2 }}</p>
                            <p>积分余额：@{{ credit2 }}</p>
                            <!-- 复销积分 -->
                            <div class="am-form-group am-form-icon">
                                <i class="am-icon-yen"></i>
                                <input type="text" v-model="user.credit5" class="am-form-field am-radius" placeholder="复销积分">
                            </div>
                            <p>操作金额：@{{ Zcredit5 }}</p>
                            <p>积分数值：@{{ credit5 }}</p>
							<!-- PK积分 -->
{{--							<div class="am-form-group am-form-icon">--}}
{{--							    <i class="am-icon-yen"></i>--}}
{{--							    <input type="text" v-model="user.credit4" class="am-form-field am-radius" placeholder="e+积分">--}}
{{--							</div>--}}
{{--							<p>操作金额：@{{ Zcredit4 }}</p>--}}
{{--							<p>e+积分数值：@{{ credit4 }}</p>--}}
							
							<div class="am-form-group am-form-icon">
							    <textarea type="" v-model="user.remark" class="am-form-field am-radius" placeholder="备注"></textarea>
							</div>
                           <!-- <div class="am-form-group am-form-icon">
                                <i class="am-icon-yen"></i>
                                <input type="text" v-model="user.voucher" class="am-form-field am-radius"
                                       placeholder="代金券">
                            </div>
                            <p>充值金额：@{{ Zvoucher }}</p>
                            <p>代金券余额：@{{ voucher }}</p> -->
                           <!-- <div class="am-form-group am-form-icon">
                                <i class="am-icon-yen"></i>
                                <input type="text" v-model="user.credit6" class="am-form-field am-radius"
                                       placeholder="启动金">
                            </div>
                            <p>充值金额：@{{ Zcredit6 }}</p>
                            <p>启动金余额：@{{ credit6 }}</p> -->
                            <!-- <textarea cols="15" rows="4"  v-model="user.remark" placeholder="请输入充值备注...."></textarea> -->
                            <div class="am-form-group am-form-icon">
                            </div>
                            <input type="hidden" value="1" name="paytype" id="paytype">
                            <p class="am-text-center"><button type="button" class="am-btn am-btn-primary am-radius am-btn-block" v-if="status == 0" v-on:click="add()">@{{ explain }}</button></p>
                            <p class="am-text-center"><button type="button" class="am-btn am-btn-danger am-radius am-btn-block" v-if="status == 0" v-on:click="reduce()">扣除</button></p>
                            <p class="am-text-center"><button type="button" class="am-btn am-btn-danger am-radius am-btn-block" v-if="status == 1">执行中...</button></p>
                        </form>
                    </div>
                </div>
                <div class="am-tab-panel am-fade" id="tab2">
                    <div class="paoduct-title-panel">
                        <hr data-am-widget="divider"  style="" class="am-divider-default am-margin-bottom-sm"/>
                        <div class="am-form-group am-form-icon">
                            <i class="am-icon-phone"></i>
                            <input type="number" pattern="\d*" v-model="user.phone" v-on:blur="upperCase()" class="am-form-field am-radius" placeholder="会员账号">
                        </div>
                        <p>修改用户：@{{ user_name }}</p>
                        <div class="am-form-group">
                            <h3>提现</h3>
                            <label class="am-checkbox-inline">
                                <input type="radio" value="1" v-model="set.is_withdraw" data-am-ucheck="" class="am-ucheck-radio">
                                <span class="am-ucheck-icons"><i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span>开启
                            </label>
                            <label class="am-checkbox-inline">
                                <input type="radio" value="0" v-model="set.is_withdraw" data-am-ucheck="" class="am-ucheck-radio">
                                <span class="am-ucheck-icons"><i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span>关闭
                            </label>
                        </div>
                        <div class="am-form-group">
                            <h3>转账</h3>
                            <label class="am-checkbox-inline">
                                <input type="radio" value="1" v-model="set.is_shift" data-am-ucheck="" class="am-ucheck-radio">
                                <span class="am-ucheck-icons"><i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span>开启
                            </label>
                            <label class="am-checkbox-inline">
                                <input type="radio" value="0" v-model="set.is_shift" data-am-ucheck="" class="am-ucheck-radio">
                                <span class="am-ucheck-icons"><i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span>关闭
                            </label>
                        </div>
                        <p>修改会员名字：</p>
                        <div class="am-form-group am-form-icon">
                            <i class="am-icon-user"></i>
                            <input type="text" v-model="set.user_name" class="am-form-field am-radius" placeholder="修改名字">
                        </div>
                        <p>修改账号和手机号：</p>
                        <div class="am-form-group am-form-icon">
                            <i class="am-icon-phone"></i>
                            <input type="number" pattern="\d*"  v-model="set.phone" class="am-form-field am-radius" placeholder="修改账号">
                        </div>
                        <a class="am-btn am-btn-danger am-radius" v-on:click="resetPass()" title="重置密码">重置密码</a>
                        <a class="am-btn am-btn-danger am-radius" v-on:click="resetPay()" title="重置支付密码">支付密码</a>
                    </div>
                    <p class="am-text-center"><button type="button" class="am-btn am-btn-danger am-radius am-btn-block" v-on:click="memberDetail()">修改</button></p>
                </div>
            </div>
        </div>

    </div>

</div>
</body>
<script src="{{ URL::asset('js/address/distpicker.data.js') }}"></script>
<script src="{{ URL::asset('js/address/distpicker.js') }}"></script>
<script src="{{ URL::asset('js/address/main.js') }}"></script>
<script src="{{ URL::asset('js/nzh/nzh.js') }}"></script>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            user: {
				'remark':'',
                'uid': '',
                'phone': '',
                'phones': '',
                'credit1': '', //购物积分币
                'credit2': '', //奖金积分
                'credit4': '', //积分
                'credit5': '', //复销积分
                'credit6': '', //启动金
                'super_level': '', //积分
                'voucher':'',
                'remark':''
            },
            explain:'充值',
            user_name:'',
            credit1:0.00,
            credit2:0.00,
            credit4:0.00,
            credit5:0.00,
            credit6:0.00,
            voucher: 0.00,
            set:{
                'is_shift':'', //0 禁止转账 1 允许
                'is_withdraw':'', //0 禁止提现 1 允许
                'phone':'', //修改的会员账号
                'user_name':'', //修改的会员名字
            },
            MicroMall: {},
            ExShop: {},
            status: 0,//判断充值
        },
        computed: {
            Zcredit1: function () {
                var nzhcn = Nzh.cn
                return nzhcn.encodeB(this.user.credit1)
            },
            Zcredit2: function () {
                var nzhcn = Nzh.cn
                return nzhcn.encodeB(this.user.credit2)
            },
            Zcredit4: function () {
                var nzhcn = Nzh.cn
                return nzhcn.encodeB(this.user.credit4)
            },
            Zcredit5: function () {
                var nzhcn = Nzh.cn
                return nzhcn.encodeB(this.user.credit5)
            },
            Zcredit6: function () {
                var nzhcn = Nzh.cn
                return nzhcn.encodeB(this.user.credit6)
            },
            Zvoucher: function () {
                var nzhcn = Nzh.cn
                return nzhcn.encodeB(this.user.voucher)
            },
        },
        methods: {
            upperCase:function () {
                if(!(/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(app.user.phone))){
                    layer.msg('请输入正确的电话号码');
                    return false;
                }
                $.post("/admin/members/memberRecharge", {'_token': '{{csrf_token()}}',class:'findsUser',phone:app.user.phone}, function (res) {
                    if (res.code) {
                        app.user.uid = res.data.uid
                        app.user_name = res.data.user_name
                        app.credit1 = res.data.credit1
                        app.credit2 = res.data.credit2
                        app.credit4 = res.data.credit4
                        app.credit5 = res.data.credit5
                        app.credit6 = res.data.credit6
                        app.voucher = res.data.voucher
                        app.set.is_shift = res.data.is_shift
                        app.set.is_withdraw = res.data.is_withdraw
                        app.ExShop = res.ExShop
                    } else {
                        layer.msg(res.data);
                    }
                });
            },
            //修改用户
            memberDetail:function () {
                if(app.user.uid == ''){
                    layer.msg('请选输入用户账号'); return
                }
                layer.confirm('确定修改'+app.user_name+'吗？', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    $.post("/admin/members/member", {'_token': '{{csrf_token()}}',class:'editUser',uid:app.user.uid,memberDetail:app.set}, function (res) {
                        if (res.code) {
                            layer.msg(res.data);
                        } else {
                            layer.msg(res.data);
                        }
                    });
                })
            },
            //重置密码
            resetPass: function() {
                layer.confirm('确定重置密码？', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    $.post("/admin/members/member",{'_token':'{{csrf_token()}}',class:'resetPass',uid:app.user.uid,Usertype:1},function (res) {
                        if(res.code){
                            layer.msg(res.data,{time: 500},function () {
                            },500);
                        } else {
                            layer.msg(res.data);
                        }
                    });
                })
            },
            //重置支付密码
            resetPay: function() {
                layer.confirm('确定重置密码？', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    $.post("/admin/members/member",{'_token':'{{csrf_token()}}',class:'resetPass',uid:app.user.uid,Usertype:2},function (res) {
                        if(res.code){
                            layer.msg(res.data,{time: 500},function () {
                            },500);
                        } else {
                            layer.msg(res.data);
                        }
                    });
                })
            },
            //充值
            add:function () {
                if(app.user.uid == ''){
                    layer.msg('请选择充值用户'); return
                }
                layer.confirm('确定充值给 '+app.user_name+' 吗？', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    app.status = 1;
                    $.post("/admin/members/memberRecharge", {'_token': '{{csrf_token()}}',class:'addRepay',uid:app.user.uid,memberPrepay:app.user}, function (res) {
                        if (res.code) {
                            app.status = 0;
                            layer.msg(res.data,{time:500},function () {
                                location.reload();
                            },500);
							window.location.href="/admin/members/index";
                        } else {
                            app.status = 0;
                            layer.msg(res.data);
                        }
                    });
                })
            },
            //扣除
            reduce:function () {
                if(app.user.uid == ''){
                    layer.msg('请选择扣除用户'); return
                }
                layer.confirm('确定扣除给 '+app.user_name+' 吗？', {
                    btn: ['确定','取消'] //按钮
                }, function() {
                    app.status = 1;
                    $.post("/admin/members/memberRecharge", {'_token': '{{csrf_token()}}',class:'minusRepay',uid:app.user.uid,memberPrepay:app.user}, function (res) {
                        if (res.code) {
                            app.status = 0;
                            layer.msg(res.data,{time:500},function () {
                                location.reload();
                            },500);
							window.location.href="/admin/members/index";
                        } else {
                            app.status = 0;
                            layer.msg(res.data);
                        }
                    });
                })
            }
        },
    });
</script>
</html>
